import { Component, OnInit, Input, EventEmitter, Output, Host, Inject, forwardRef, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
import { HttpClient } from '@angular/common/http';
import { Service } from '../../../server/server';

declare var $: any;

@Component({
  selector: 'app-privilege-delete',
  templateUrl: './privilege-delete.component.html'
})
export class PrivilegeDeleteComponent implements OnInit {

  @Input()
  private getRmTabId: string;

  constructor(private http: HttpClient, private server: Service, private removeTableService: RemoveTableService, ) { }

  ngOnInit() {
  }

  @Output()
  deleteOutput: EventEmitter<string> = new EventEmitter();

  confirmRm() {
    //console.log(this.getRmTabId.split(','));
    //let operationId : string;
    //	let data : object;
    //data = { operationId : this.getRmTabId.split(',')};

    let url = this.server.baseUrl+'admin/operations/delete';
    this.removeTableService.confirmRemove("operationId", url).then((res: any) => {
      this.deleteOutput.emit(res.result_code);
      if (res.result_code === '0000') {
        this.server.prompt = { prompt: true, success: true, fail: false, promptStatement: res.message }
        this.server.promptclose;
        $("#delete").modal("hide");
      } else {
        this.server.prompt = { prompt: true, success: false, fail: true, promptStatement: res.message }
        this.server.promptclose;
      }
    }).catch()
  }

}
